package NC;

public class NC23 {
    public ListNode partition (ListNode head, int x) {
        // write code here
        ListNode big = new ListNode(0);
        ListNode small = new ListNode(0);
        ListNode temp = head,bt=big,st=small;
        while (temp!=null){
            if(temp.val>=x){
                bt.next = temp;
                bt = temp;
            }else {
                st.next = temp;
                st=temp;
            }
            temp = temp.next;
        }
        st.next = big.next;
        bt.next = null;
        return small.next;
    }
}
